using System.Collections.Generic;
using System.Web.Mvc;
using Tools.Domain.Specifications.Constraints;
using Tools.Domain.Specifications.Client.Building;
using Web.App.Infrastructure.Localization.Contract;
using Webshop20.Application.DataTransferObjects;
using Webshop20.Domain.Customers.Core;
using Webshop20.Domain.Security.Authentication.Core;

namespace Webshop20.Presentation
{
    public class RegistrationForm : RegistrationBase
    {

        private const string FORM_NAME = "?";
        private readonly IConstraintSet<Customer> customerConstraintSet;
        private readonly IConstraintSet<Account> accountConstraintSet;
        private readonly IEnumerable<ControllQuestionDTO> controllQuestions;
        private readonly IClientSideValidationBuilder clientSideValidationBuilder;

        
        public RegistrationForm(ILocalisationService localisationService, 
                                                IPresentationState state, 
                                                NewRegistrationDTO newRegistrationDTO, 
                                                IConstraintSet<Customer> customerConstraintSet, 
                                                IConstraintSet<Account> accountConstraintSet, 
                                                IEnumerable<ControllQuestionDTO> controllQuestions, 
                                                IClientSideValidationBuilder clientSideValidationBuilder, 
                                                string accountInterimKey, 
                                                string customerInterimKey) 
            : base(localisationService, newRegistrationDTO, accountInterimKey, customerInterimKey)
        {
            this.newRegistrationDTO = newRegistrationDTO;
            this.clientSideValidationBuilder = clientSideValidationBuilder;
            this.controllQuestions = controllQuestions;
            this.accountConstraintSet = accountConstraintSet;
            this.customerConstraintSet = customerConstraintSet;
        }




        public string UnestedValidationCode
        {
            get 
            { 
              return clientSideValidationBuilder.Build(customerConstraintSet, false, FORM_NAME) +
                                     clientSideValidationBuilder.Build(accountConstraintSet, false, FORM_NAME);


            }
        }

        public SelectList ControllQuestionsListbox 
        { 
            get
            {
                return new SelectList(controllQuestions, newRegistrationDTO.ControlQuestionId);
            }

        }
    }
}